package com.it.service.impl;

import com.github.pagehelper.PageHelper;
import com.it.dao.VIPDao;
import com.it.domain.VIP_Management;
import com.it.service.VIP_ManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("vipmanagementService")
public class VIP_ManagementServiceImpl implements VIP_ManagementService {

    @Autowired
    private VIPDao vipdao;

    //存储会员信息
    @Override
    public void saveVIPer(VIP_Management vipManagement) {

        vipdao.saveVIPer(vipManagement);

    }

    //查询所有会员信息
    @Override
    public List<VIP_Management> FindAllVIP(int page,int size) {


        //参数pageNum是页码值   参数pageSize代表是每页显示条数
        PageHelper.startPage(page,size);
        return vipdao.FindAllVIP();
    }

    /**
     * 根据id查询信息
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<VIP_Management> FindById(int id ,int page, int size) {

        PageHelper.startPage(page,size);
        return vipdao.FindById(id);

    }

    /**
     * 根据id删除会员
     * @param id
     * @return
     */
    @Override
    public boolean delVip(int id) {
        List<VIP_Management> list = vipdao.FindById(id);
        //判断list是否为空
        if (null == list || list.size() ==0 ){
            //为空
            return false;
        }else {

            vipdao.delVip(id);
            return true;
        }
    }

    /**
     * 根据id修改会员信息
     * @param vipManagement
     */
    @Override
    public void changeVip(VIP_Management vipManagement){
        vipdao.changeVip(vipManagement);
    }

    /**
     * 根据姓名模糊查询
     * @param name
     */
    @Override
    public List<VIP_Management> FindByName(String name,int page,int size) {
        PageHelper.startPage(page,size);
        return vipdao.FindByName(name);

    }


}
